package br.com.caelum.vraptor.util;

	import javax.inject.Inject;

	import br.com.caelum.vraptor.AroundCall;
	import br.com.caelum.vraptor.Intercepts;
	import br.com.caelum.vraptor.Result;
	import br.com.caelum.vraptor.auth_annotations.Restrito;
	import br.com.caelum.vraptor.components.ProfessorSessioned;
	import br.com.caelum.vraptor.controller.IndexController;
	import br.com.caelum.vraptor.interceptor.AcceptsWithAnnotations;
	import br.com.caelum.vraptor.interceptor.SimpleInterceptorStack;

	@Intercepts
	@AcceptsWithAnnotations(Restrito.class)
	public class Interceptorprof {
	        
	        @Inject
	        private ProfessorSessioned professorSessioned;
	        @Inject
	        private Result result;
	        
	        @AroundCall
	        public void intercept(SimpleInterceptorStack stack){
	                if(professorSessioned.isLogado()){stack.next();System.out.println("Logado");}
	                else{
	                        result.redirectTo(IndexController.class).loginprof();
	                }
	        }

}
